#!/bin/bash
#
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

setup:
- command: [docker, run, -d, -e, ZOO_4LW_COMMANDS_WHITELIST="*", --name, zk-$UNIQUE-id, --restart, always, "marketplace.gcr.io/google/zookeeper3"]
- command: [docker, run, -d, -p, "8983:8983", -e, ZK_HOST=zk, --link, "zk-$UNIQUE-id:zk", --name, solr-$UNIQUE-id, '$IMAGE']
- command: [sleep, 5s]


teardown:
- command: [docker, stop, zk-$UNIQUE-id, solr-$UNIQUE-id]
- command: [docker, rm, zk-$UNIQUE-id, solr-$UNIQUE-id]

target: solr-$UNIQUE-id
tests:
- name: Create successfully "mycollection"
  command: [solr, create_collection, -c, mycollection]
  expect:
    stdout:
      matches: "Created collection 'mycollection'"

- name: Ping successfully "mycollection"
  command: [wget, -O, -, --no-verbose, "http://localhost:8983/solr/mycollection/admin/ping?distrib=true&wt=xml"]
  expect:
    stdout:
      matches: '<str name="status">OK</str>'
